VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "xlUnitTestHarness"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit

Private testBook As Workbook
Public appBook As Workbook

Public Property Get book() As Workbook
    If Not Exists Then
        AttemptHookup
    End If
    If Exists Then
        Set book = testBook
    End If
End Property

Public Property Set book(bookToUse As Workbook)
    Set testBook = bookToUse
End Property

Public Sub Activate()
    If Exists Then
        testBook.Activate
    End If
End Sub

Public Property Get Exists() As Boolean
    Exists = (Not testBook Is Nothing)
End Property

Public Sub AttemptHookup()

Dim wb As Workbook
Dim comp As Object

    For Each wb In Workbooks
        If wb.VBProject.Protection = vbext_pp_none Then
            For Each comp In wb.VBProject.VBComponents
                If TypeName(comp) = "VBComponent" Then
                    If comp.Name = "xlUnitUI" Then
                        Application.Run wb.Name & "!HookupToxlUnit"
                        Exit For
                    End If
                End If
            Next
        End If
    Next

    testBook.Activate

    Set appBook = Workbooks(Range("[" & testBook.Name & "]Params!" & TESTHARNESS_FILENAME_RANGENAME).Value)

End Sub
